package com.yanqu.road.server.cmd.activity.stronghold.eliminate;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.strongholdwar.StrongholdActivityMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_STRONGHOLD_WAR_ELIMINATION_ENTER_UNION,desc = "先择挑战联盟")
public class StrongholeChooseUnionCmd extends AbstractCommand {
    private int id;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        StrongholdWarProto.ChooseChallengeUnionReqMsg req = StrongholdWarProto.ChooseChallengeUnionReqMsg.parseFrom(packet.getBytes());
        id = req.getId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = StrongholdActivityMgr.getOpenActivityInfo();
        if (activityInfo != null) {
            StrongholdWarProto.CrossChooseChallengeUnionReqMsg.Builder req = StrongholdWarProto.CrossChooseChallengeUnionReqMsg.newBuilder();
            req.setActivityId(activityInfo.getActivityId());
            req.setId(id);
            player.sendUnionActivityGroupPacket(CrossProtocol.C_CROSS_STRONGHOLD_CHOOSE_UNION, req, req.getActivityId());
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
